from lib.tb import *
# import threading


if __name__ == '__main__':
    # for example, buy_list={'21381820676','111111','2222222'}
    buy_list={'21381820676'}

    config={
        'checkOnSaleTime': 0.1,   # every x sceonds to check is on sale 
        'username': 'timin1922',
        'password' : 'tangzhimin0122',
        'debug': False   # True, False
    }

    stream = Taobao(config)
    stream.login()
    # time.sleep(1)

    # print stream.isOnSale('http://item.taobao.com/item.htm?id=17543277355')
    # stream.buy('21381820676')
    stream.secondKill('http://item.taobao.com/item.htm?id=17543277355', '17543277355')
    import profile 
    # profile.run("stream.buy('19306595397')")
    # profile.run("stream.secondKill('http://item.taobao.com/item.htm?id=19324691771', '19324691771')")
    # for id in buy_list:
    #     url ='http://item.taobao.com/item.htm?id=%s' % id
    #     t = threading.Thread(target=stream.secondKill, args=([url, id]))
    #     t.start()
